package com.benew.ntt.evaluate.sdk

import com.benew.ntt.evaluate.constant.EvalConst

/**
 * SDK配置信息
 */
class EvalSDKConfig {

    class Builder {
        @EvalSDKPlatform
        private var platform = EvalSDKPlatform.YD

        private var deviceId: String? = null

        private var token: String? = null
        private var host: String? = null
        private var warrantIdTime: Long? = null

        @EvalSDKType
        private var evalSDKType:Int? = null

        @EvalSDKDevice
        private var deviceType = EvalSDKDevice.R2
        private var recordFilePath: String? = null
        private var scoreFilePath: String? = null
        private var levelFilePath: String? = null

        /**
         * 评测平台,默认有道
         */
        fun setPlatform(@EvalSDKPlatform platform: Int): Builder {
            this.platform = platform
            return this
        }

        /**
         *  设备ID
         */
        fun setDeviceId(deviceId: String?): Builder {
            this.deviceId = deviceId
            return this
        }

        /**
         * token
         */
        fun setToken(token: String?): Builder {
            this.token = token
            return this
        }

        /**
         * 评测鉴权的接口
         */
        fun setHost(host: String?): Builder {
            this.host = host
            return this
        }

        /**
         * WarrantId过期前N小时重新获取
         */
        fun setWarrantIdTime(warrantIdTime: Long?): Builder {
            this.warrantIdTime = warrantIdTime
            return this
        }

        /**
         * 评测类型：混合，在线，离线
         * 该值为null的情况下，网络连接会使用混合，未连接使用离线
         * ps：目前只支持先声配置该项
         */
        fun setEvalSDKType(@EvalSDKType evalSDKType: Int): Builder {
            this.evalSDKType = evalSDKType
            return this
        }

        /**
         * 评测设备类型
         */
        fun setDeviceType(@EvalSDKPlatform deviceType: Int): Builder {
            this.deviceType = deviceType
            return this
        }

        /**
         * 录音路径
         *
         * 如果值为空，则会使用以下默认路径：
         * 当[deviceType]==[EvalSDKDevice.R2],则默认路径为[EvalConst.RECORD_FILE_PATH_R2]，
         * 当[deviceType]==[EvalSDKDevice.OLED],则默认路径为[EvalConst.RECORD_FILE_PATH_OLED]
         */
        fun setRecordFilePath(recordFilePath: String?): Builder {
            this.recordFilePath = recordFilePath
            return this
        }

        /**
         * 分数难易度分数配置路径
         *
         * 如果值为空，则会使用以下默认路径：
         * 当[deviceType]==[EvalSDKDevice.R2],则默认路径为[EvalConst.SCORE_FILE_PATH_R2]，
         * 当[deviceType]==[EvalSDKDevice.OLED],则默认路径为[EvalConst.SCORE_FILE_PATH_OLED]
         */
        fun setScoreFilePath(scoreFilePath: String?): Builder {
            this.scoreFilePath = scoreFilePath
            return this
        }

        /**
         * 分数难易度分数配置路径
         *
         * 如果值为空，则会使用以下默认路径：
         * 当[deviceType]==[EvalSDKDevice.R2],则默认路径为[EvalConst.LEVEL_FILE_PATH_R2]，
         * 当[deviceType]==[EvalSDKDevice.OLED],则默认路径为[EvalConst.LEVEL_FILE_PATH_OLED]
         */
        fun setLevelFilePath(levelFilePath: String?): Builder {
            this.levelFilePath = levelFilePath
            return this
        }

        fun build(): EvalSDKConfig {
            val evalSDKConfig = EvalSDKConfig()
            evalSDKConfig.platform = platform
            evalSDKConfig.deviceId = deviceId
            evalSDKConfig.token = token
            evalSDKConfig.host = host
            evalSDKConfig.warrantIdTime = warrantIdTime
            evalSDKConfig.evalSDKType = evalSDKType
            evalSDKConfig.deviceType = deviceType
            evalSDKConfig.recordFilePath = recordFilePath
            evalSDKConfig.scoreFilePath = scoreFilePath
            evalSDKConfig.levelFilePath = levelFilePath
            return evalSDKConfig
        }
    }

    /**
     * 评测平台,默认有道
     */
    @EvalSDKPlatform
    private var platform = EvalSDKPlatform.YD
    fun getPlatform() = platform

    /**
     *  设备ID
     */
    private var deviceId: String? = null
    fun getDeviceId() = deviceId

    /**
     * token
     */
    var token: String? = null

    /**
     * 评测鉴权的接口
     */
    var host: String? = null

    /**
     * WarrantId过期前N小时重新获取
     */
    var warrantIdTime: Long? = null

    /**
     * 评测类型：混合，在线，离线
     * 该值为null的情况下，网络连接会使用混合，未连接使用离线
     * ps：目前只支持先声配置该项
     */
    @EvalSDKType
    var evalSDKType:Int? = null

    /**
     * 评测设备类型
     */
    @EvalSDKDevice
    private var deviceType = EvalSDKDevice.R2
    fun getDeviceType() = deviceType

    /**
     * 录音路径
     *
     * 如果值为空，则会使用以下默认路径：
     * 当[deviceType]==[EvalSDKDevice.R2],则默认路径为[EvalConst.RECORD_FILE_PATH_R2]，
     * 当[deviceType]==[EvalSDKDevice.OLED],则默认路径为[EvalConst.RECORD_FILE_PATH_OLED]
     */
    var recordFilePath: String? = null

    /**
     * 分数难易度分数配置路径
     *
     * 如果值为空，则会使用以下默认路径：
     * 当[deviceType]==[EvalSDKDevice.R2],则默认路径为[EvalConst.SCORE_FILE_PATH_R2]，
     * 当[deviceType]==[EvalSDKDevice.OLED],则默认路径为[EvalConst.SCORE_FILE_PATH_OLED]
     */
    var scoreFilePath: String? = null

    /**
     * 分数难易度分数配置路径
     *
     * 如果值为空，则会使用以下默认路径：
     * 当[deviceType]==[EvalSDKDevice.R2],则默认路径为[EvalConst.LEVEL_FILE_PATH_R2]，
     * 当[deviceType]==[EvalSDKDevice.OLED],则默认路径为[EvalConst.LEVEL_FILE_PATH_OLED]
     */
    var levelFilePath: String? = null

}